/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bs.app.Util;

import bs.app.android.RecordStore;

/**
 *
 * @author Administrator
 */
public class Utility {
    public static void saveMsisdn(String value){
        clearRecordBoard("msisdn");
        saveRMS("msisdn", value);
    }
    public static void saveRMS(String recordName, String value) {
        try {
            RecordStore rec = RecordStore.openRecordStore(recordName, true);
            byte data[]=value.getBytes();
            rec.addRecord(data, 0, data.length);
            rec.closeRecordStore();
        } catch (Exception e) {
        }
    }

    public static void clearRecordBoard(String recordName) {
        try {
            RecordStore.deleteRecordStore(recordName);
        } catch (Exception e) {
        }
    }

    public static String loadRMS(String recordName) {
        String value="";
        try {
            RecordStore rec = RecordStore.openRecordStore(recordName, false);
            value=new String(rec.getRecord(1));
            rec.closeRecordStore();            
        } catch (Exception e) {

        }
        return value;
    }
    public static boolean isValidUserId(String userId) {
         if (userId == null || "".equals(userId)) {
            return false;
         }
         if(!isDigit(userId) || userId.length() < 9){
             return false;
         }
         return true;
   }
   public static boolean isDigit(String sInput) {
      if (sInput == null || sInput.equals(""))
         return false;
      for (int i = 0; i < sInput.length(); i++) {
         if (!Character.isDigit(sInput.charAt(i)))
            return false;
      }
      return true;
   }
}
